home *** CD-ROM | disk | FTP | other *** search
/ Champak 138 / Volume 138 Aug 19 2011 - Damaged.iso / Games / shadez.swf / scripts / Local / Game / World / CMouse.as < prev    next >
Encoding:
Text File  |  2011-08-19  |  11.2 KB  |  410 lines

  1.  
  2. {
  3.    if(true)
  4.    {
  5.       CMouse = ┬º┬ºnewclass(CMouse,Sprite);
  6.    }
  7. }
  8.  
  9. package Local.Game.World
  10. {
  11.    import Local.*;
  12.    import Local.Audio.*;
  13.    import Local.Game.*;
  14.    import Local.Game.HUD.*;
  15.    import Local.Game.Level.*;
  16.    import Local.Game.Thing.*;
  17.    import Local.Game.World.Map.*;
  18.    import Local.Game.World.Map.Cell.*;
  19.    import STC9.IO.*;
  20.    import flash.display.*;
  21.    import flash.events.*;
  22.    import flash.filters.*;
  23.    import flash.geom.*;
  24.    import flash.ui.*;
  25.    
  26.    public class CMouse extends Sprite
  27.    {
  28.       
  29.       public static const ACTION_SELECTFRIEND:String = "ACTION_SELECTFRIEND";
  30.       
  31.       public static const ACTION_LAUNCHSTRIKE:String = "ACTION_LAUNCHSTRIKE";
  32.       
  33.       public static var mFilters:Object;
  34.       
  35.       {
  36.          if(true)
  37.          {
  38.             ACTION_LAUNCHSTRIKE = "ACTION_LAUNCHSTRIKE";
  39.             ACTION_SELECTFRIEND = "ACTION_SELECTFRIEND";
  40.          }
  41.       }
  42.       
  43.       public var mLastOverThing:*;
  44.       
  45.       public var mClick:Boolean;
  46.       
  47.       public var mWorld:CWorld;
  48.       
  49.       private var mPointerID:String;
  50.       
  51.       private var _CurrentFilter:Object;
  52.       
  53.       private var _Scope:Boolean;
  54.       
  55.       private var mInitialized:Boolean = false;
  56.       
  57.       private var mPointers:Object;
  58.       
  59.       public var mClickPosition:CPosition;
  60.       
  61.       public var mCurrentPosition:CPosition;
  62.       
  63.       public var mClickThing:*;
  64.       
  65.       private var _LocalPosition:Point;
  66.       
  67.       public var mOverThing:*;
  68.       
  69.       public function CMouse(param1:CWorld)
  70.       {
  71.          mInitialized = false;
  72.          super();
  73.          mWorld = param1;
  74.          addEventListener(Event.ADDED_TO_STAGE,Initialize);
  75.       }
  76.       
  77.       public static function DuplicateObject(param1:Object) : Object
  78.       {
  79.          var _loc2_:Object = null;
  80.          var _loc3_:String = null;
  81.          _loc2_ = new Object();
  82.          for(_loc3_ in param1)
  83.          {
  84.             _loc2_[_loc3_] = param1[_loc3_];
  85.          }
  86.          return _loc2_;
  87.       }
  88.       
  89.       public function ClearFilter() : void
  90.       {
  91.          if(true)
  92.          {
  93.             mCurrentFilter = mFilters["normal"];
  94.          }
  95.       }
  96.       
  97.       public function UpdatePointer() : void
  98.       {
  99.          if(true)
  100.          {
  101.             ┬º┬ºpush(mPointerID == "normal");
  102.             if(!(mPointerID == "normal"))
  103.             {
  104.                ┬º┬ºpop();
  105.                if(true)
  106.                {
  107.                   addr28:
  108.                   if(!_Scope)
  109.                   {
  110.                      if(true)
  111.                      {
  112.                         Mouse.show();
  113.                         visible = false;
  114.                      }
  115.                      ┬º┬ºgoto(addr49);
  116.                   }
  117.                   else
  118.                   {
  119.                      Mouse.hide();
  120.                   }
  121.                   ┬º┬ºgoto(addr49);
  122.                }
  123.                visible = true;
  124.                ┬º┬ºgoto(addr49);
  125.             }
  126.             ┬º┬ºgoto(addr28);
  127.          }
  128.          addr49:
  129.       }
  130.       
  131.       private function ACTION_SelectFriend() : void
  132.       {
  133.          dispatchEvent(new Event(ACTION_SELECTFRIEND));
  134.          ClearFilter();
  135.          CAudio.PlayGlobalSound(Click);
  136.       }
  137.       
  138.       public function get mLocalPosition() : Point
  139.       {
  140.          return _LocalPosition;
  141.       }
  142.       
  143.       public function Process() : void
  144.       {
  145.          if(CKeyboard.IsReleased("ESCAPE"))
  146.          {
  147.             Cancel();
  148.          }
  149.          ┬º┬ºpush(mLastOverThing);
  150.          if(true)
  151.          {
  152.             if(┬º┬ºpop())
  153.             {
  154.                if(true)
  155.                {
  156.                   ┬º┬ºpop();
  157.                   ┬º┬ºpush(mLastOverThing == mOverThing);
  158.                }
  159.                ┬º┬ºpush(!┬º┬ºpop());
  160.             }
  161.          }
  162.          if(┬º┬ºpop())
  163.          {
  164.             mLastOverThing.mMouseOver = false;
  165.          }
  166.          Process_Filter();
  167.          mClick = false;
  168.          mLastOverThing = mOverThing;
  169.          mOverThing = null;
  170.       }
  171.       
  172.       public function get mHUD() : CHUD
  173.       {
  174.          return mWorld.mGame.mHUD;
  175.       }
  176.       
  177.       public function AddPointer(param1:String, param2:Class) : void
  178.       {
  179.          mPointers[param1] = new param2();
  180.       }
  181.       
  182.       private function Process_Filter() : void
  183.       {
  184.          var _loc1_:* = null;
  185.          var _loc2_:String = null;
  186.          ┬º┬ºpush(!!mOverThing ? (mOverThing.mGroupID == CThingContainer.GROUPID_ENEMY ? (!!mOverThing.mTargetAirbourne ? "enemyair" : "enemyground") : "friend") : "position");
  187.          if(true)
  188.          {
  189.             _loc1_ = ┬º┬ºpop();
  190.             _loc2_ = (mClick ? "click" : "over") + _loc1_;
  191.             mClickThing = mClick && mOverThing ? mOverThing : null;
  192.             ┬º┬ºpush(_loc2_);
  193.          }
  194.          if(┬º┬ºpop() == "overfriend")
  195.          {
  196.             mOverThing.mMouseOver = true;
  197.          }
  198.          if(mCurrentFilter[_loc2_])
  199.          {
  200.             var _loc3_:* = typeof mCurrentFilter[_loc2_];
  201.             if(true)
  202.             {
  203.                if("string" !== _loc3_)
  204.                {
  205.                   if("boolean" === _loc3_)
  206.                   {
  207.                      ┬º┬ºgoto(addr122);
  208.                   }
  209.                   else
  210.                   {
  211.                      ┬º┬ºpush("function" === _loc3_ ? 2 : 3);
  212.                   }
  213.                }
  214.                ┬º┬ºgoto(addr131);
  215.             }
  216.             ┬º┬ºgoto(addr127);
  217.          }
  218.          else
  219.          {
  220.             SetPointer("normal");
  221.          }
  222.          addr131:
  223.          switch(true ? 0 : 1)
  224.          {
  225.             case 0:
  226.                SetPointer(mCurrentFilter[_loc2_]);
  227.                break;
  228.             case 1:
  229.                SetPointer(_loc2_);
  230.                break;
  231.             case 2:
  232.                mCurrentFilter[_loc2_]();
  233.          }
  234.       }
  235.       
  236.       public function set mLocalPosition(param1:Point) : void
  237.       {
  238.          if(true)
  239.          {
  240.             x = param1.x;
  241.             y = param1.y;
  242.          }
  243.       }
  244.       
  245.       public function Cancel() : void
  246.       {
  247.          ClearFilter();
  248.          mHUD.DeselectAll();
  249.          mClick = false;
  250.          if(mLastOverThing)
  251.          {
  252.             mLastOverThing.mMouseOver = false;
  253.          }
  254.       }
  255.       
  256.       public function Initialize(param1:Event = null) : void
  257.       {
  258.          if(true)
  259.          {
  260.             removeEventListener(Event.ADDED_TO_STAGE,Initialize);
  261.             if(true)
  262.             {
  263.                mPointers = new Object();
  264.                if(true)
  265.                {
  266.                   mCurrentPosition = new CPosition();
  267.                   if(true)
  268.                   {
  269.                      mLocalPosition = new CPosition();
  270.                      if(true)
  271.                      {
  272.                         mClickPosition = new CPosition();
  273.                         if(true)
  274.                         {
  275.                            AddPointer("overposition",Pointer_Target);
  276.                         }
  277.                         AddPointer("overfriend",Pointer_OverThing);
  278.                      }
  279.                      AddPointer("overenemy",Pointer_OverTarget);
  280.                   }
  281.                   AddPointer("invalid",Pointer_InvalidTarget);
  282.                }
  283.                mInitialized = true;
  284.             }
  285.             SetupFilters();
  286.          }
  287.       }
  288.       
  289.       private function SetPointer(param1:String) : void
  290.       {
  291.          while(numChildren)
  292.          {
  293.             removeChildAt(0);
  294.          }
  295.          if(param1 != "normal")
  296.          {
  297.             addChild(mPointers[param1]);
  298.          }
  299.          mPointerID = param1;
  300.          UpdatePointer();
  301.       }
  302.       
  303.       public function set mScope(param1:Boolean) : void
  304.       {
  305.          _Scope = param1;
  306.          UpdatePointer();
  307.       }
  308.       
  309.       public function set mCurrentFilter(param1:Object) : void
  310.       {
  311.          _CurrentFilter = DuplicateObject(param1);
  312.          UpdatePointer();
  313.       }
  314.       
  315.       private function ACTION_LaunchStrike() : void
  316.       {
  317.          dispatchEvent(new Event(ACTION_LAUNCHSTRIKE));
  318.          Cancel();
  319.          CAudio.PlayGlobalSound(Click);
  320.       }
  321.       
  322.       public function SetupFilters() : void
  323.       {
  324.          var _loc1_:Object = null;
  325.          mFilters = new Object();
  326.          _loc1_ = mFilters["normal"] = new Object();
  327.          if(true)
  328.          {
  329.             _loc1_["overposition"] = "normal";
  330.             if(true)
  331.             {
  332.                _loc1_["overfriend"] = "overfriend";
  333.                _loc1_["clickfriend"] = ACTION_SelectFriend;
  334.             }
  335.             _loc1_["state"] = "none";
  336.          }
  337.          _loc1_ = mFilters["unit"] = DuplicateObject(mFilters["default"]);
  338.          _loc1_ = mFilters["strike"] = DuplicateObject(mFilters["default"]);
  339.          if(true)
  340.          {
  341.             _loc1_["overposition"] = "overposition";
  342.             if(true)
  343.             {
  344.                _loc1_["clickposition"] = ACTION_LaunchStrike;
  345.                if(true)
  346.                {
  347.                   _loc1_["overenemyair"] = "overenemy";
  348.                   _loc1_["overenemyground"] = "overenemy";
  349.                }
  350.                _loc1_["clickenemyair"] = ACTION_LaunchStrike;
  351.             }
  352.             _loc1_["clickenemyground"] = ACTION_LaunchStrike;
  353.          }
  354.          _loc1_ = mFilters["strikeLG"] = DuplicateObject(mFilters["strike"]);
  355.          if(true)
  356.          {
  357.             _loc1_["overenemyair"] = "invalid";
  358.             _loc1_["clickenemyair"] = "invalid";
  359.          }
  360.          _loc1_ = mFilters["strikeLA"] = DuplicateObject(mFilters["strike"]);
  361.          _loc1_["overenemyground"] = "invalid";
  362.          _loc1_["clickenemyground"] = "invalid";
  363.          _loc1_ = mFilters["strikeL"] = DuplicateObject(mFilters["strike"]);
  364.          if(true)
  365.          {
  366.             _loc1_["overenemyair"] = "invalid";
  367.             if(true)
  368.             {
  369.                _loc1_["clickenemyair"] = "invalid";
  370.                _loc1_["overenemyground"] = "invalid";
  371.             }
  372.             _loc1_["clickenemyground"] = "invalid";
  373.          }
  374.          _loc1_ = mFilters["strikeAG"] = DuplicateObject(mFilters["strike"]);
  375.          _loc1_["overposition"] = "invalid";
  376.          _loc1_["clickposition"] = "invalid";
  377.          _loc1_ = mFilters["strikeA"] = DuplicateObject(mFilters["strike"]);
  378.          _loc1_["overposition"] = "invalid";
  379.          _loc1_["clickposition"] = "invalid";
  380.          _loc1_["overenemyground"] = "invalid";
  381.          _loc1_["clickenemyground"] = "invalid";
  382.          _loc1_ = mFilters["strikeG"] = DuplicateObject(mFilters["strike"]);
  383.          _loc1_["overposition"] = "invalid";
  384.          _loc1_["clickposition"] = "invalid";
  385.          _loc1_["overenemyair"] = "invalid";
  386.          _loc1_["clickenemyair"] = "invalid";
  387.          ClearFilter();
  388.       }
  389.       
  390.       public function get mCurrentFilter() : Object
  391.       {
  392.          return _CurrentFilter;
  393.       }
  394.       
  395.       public function get mScope() : Boolean
  396.       {
  397.          return _Scope;
  398.       }
  399.       
  400.       public function Dispose() : void
  401.       {
  402.          if(parent)
  403.          {
  404.             parent.removeChild(this);
  405.          }
  406.          Mouse.show();
  407.       }
  408.    }
  409. }
  410.